#include <string>
#include <iostream>
using namespace std;
#include "Shot.h"
#include "Time.h"

Shot::Shot( ): Event("SH")
{}


//I dont think this function is ever used. 
Shot::Shot(char team, int playerNumber , int points, bool made , Time shotTime): Event("SH", shotTime)
{
m_team=team;
m_points=points;
m_made=made;
m_shotTime=shotTime;

m_commitPlayer=playerNumber;

}

ostream& operator<<(ostream& out, Shot& attempt )
{
string status;
if (attempt.m_made)
status="MADE";
else 
status="MISS";

out<<"Team: "<<attempt.m_team<<" Player no: "<<attempt.m_commitPlayer<< " Type: "<< attempt.m_points<<" Status: "<< status<< " Time: " << attempt.m_shotTime<<endl;

}


bool Shot::getMade()
{
return m_made;
}

int Shot::getPoints()
{
return m_points;
}


int Shot::getPer()
{
return m_shotTime.getPeriod();
}




bool Shot::assignValues() 
{
int m_made_input;
bool goodInput=true;
//SH [Time] [Team] [Number] 1/2/3 0/1
cin>>m_shotTime;
cin>>m_team;
cin>>m_commitPlayer;
cin>>m_points;
cin>>m_made_input;
m_eventTime=m_shotTime;
m_shotTime.reverseTime();


	if (m_made_input==1)
	m_made=true;
	else
	m_made=false;	

	if(cin.fail())
	{
	cin.clear();
	cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
	goodInput=false;
	}

//Check if shot type is good input
	if ((m_points!=2)&&(m_points!=3)&&(m_points!=1))
	{
	goodInput=false;
	}
//Check if player number is good input
	if ((m_commitPlayer > 100) || (m_commitPlayer <0 ))
	{
	goodInput=false;
	}
	if(!m_shotTime.checkTimeInput())
	{
	goodInput=false;
	}	
	if((m_team!='H')&&(m_team!='h')&&(m_team!='A')&&(m_team!='a'))
	{
	goodInput=false;
	}
return goodInput;
}

